package org.arain.baseii.system.organization;

import org.arain.baseii.utils.ArainResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 
* <p>Title:OrganizationController </p>
* @author Arain
* @date2017年9月4日
 */
@Controller
@RequestMapping("system/organization")
public class OrganizationController {
	@Autowired
	private OrganizationService organizationService;
	@RequestMapping("list_01")
	public String list_01(Model model) {
		model.addAttribute("mapArray",organizationService.load_organization());
		return "system/organization/list_01";
	}
	
	@RequestMapping(value="load_datagrid.do",produces="text/json;charset=UTF-8")
	@ResponseBody
	public String load_data(OrganizationDto dto) {
		return organizationService.load_datagrid(dto);
	}
	
	@RequestMapping("add_01")
	public String add_01(Model model,OrganizationDto dto) {
		dto.setEnabled("1");
		model.addAttribute("OrganizationDto", dto);
		return "system/organization/add_01";
	}
	
	@RequestMapping(value="load_pid.do",produces="text/json;charset=UTF-8")
	@ResponseBody
	public String load_pid(OrganizationDto dto) {
		return organizationService.load_pid(dto);
	}
	
	@RequestMapping("save.do")
	@ResponseBody
	public ArainResult save_01(OrganizationDto dto) {
		return organizationService.save_01(dto);
	}
	
	@RequestMapping("edit_01")
	public String edit_01(Model model,OrganizationDto dto) {
		dto=organizationService.load_01(dto);
		model.addAttribute("OrganizationDto", dto);
		return "system/organization/add_01";
	}
}
